-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FIFO handling on Solaris #70
Conversation
606b554
to
725fc4b
Compare
Starting with today's restic master branch (restic/restic@24a2e5c), I updated
After building restic with the updated xattr package, restic is able to successfully backup a directory containing a FIFO file:
That said... as far as I can tell, neither restic 0.14.0 release nor this updated build are actually backing up xattrs on regular files, but since the behavior is the same in the release version I'm guessing that has nothing to do with this change. (Although I see there is still an open issue in restic about not backing up ACLs on SmartOS, for example, so this appears to be a known issue.) |
Most of the changes aren't directly relevant to this issue, only the O_NONBLOCK is necessary. Reverting back many of the changes from #62 concerns me due to the file descriptor lifetime issues addressed there. Due to errors with doors and whatnot, my local copy of
Which isn't pretty and adds an extra system call for every path but avoids problems backing up parts of the root filesystem without having to add files to the exclude list. There are still filesystems like tmpfs which don't support xattrs at all, but you get |
On Solaris, files need to be opened to obtain or change their attributes. But opening a FIFO file causes the calling thread to block until the write end is opened. Files are now opened using O_NONBLOCK to prevent this from happening. Should fix restic/restic#4003. Also fix comment on stringsFromByteSlice.
725fc4b
to
93ee36a
Compare
Oh, I wasn't aware that that's what the NewFile calls were for. I just wasn't sure whether I could actually pass O_NONBLOCK to os.OpenFile. Pushed a smaller patch that does that instead. Judging from how os.O_* is implemented on Solaris, this should work, though it's a bit of a hack to combine os.O_* and unix.O_* constants. |
Thank you guys - great work! |
@greatroar I have the same hack in the copy I've been using but you're right--- it doesn't seem legal. |
Passing this flag to os.Open works, but this relies on undocumented implementation details of package os.
Pushed a version that opens with unix.Open but uses os.NewFile on the resulting fds. |
This looks good to me. I will see about testing. |
xattr.Remove hangs with your built-in tests, see patch below. Also, the tests hang when I remove the O_NONBLOCK from xattr_solaris.go (as one would expect). I tried adding
|
This ensures the test runs in a bounded amount of time:
|
Ok, added O_NONBLOCK in removexattr, and O_CLOEXEC while I was at it. I'd rather leave timeouts to the go test command. |
Did anyone verify and also can approve the PR (so, I can be sure it does not break anything and I can merge it)? |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/pkg/xattr](https://togithub.com/pkg/xattr) | `v0.4.9` -> `v0.4.10` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fpkg%2fxattr/v0.4.10?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fpkg%2fxattr/v0.4.10?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fpkg%2fxattr/v0.4.9/v0.4.10?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fpkg%2fxattr/v0.4.9/v0.4.10?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pkg/xattr (github.com/pkg/xattr)</summary> ### [`v0.4.10`](https://togithub.com/pkg/xattr/releases/tag/v0.4.10) [Compare Source](https://togithub.com/pkg/xattr/compare/v0.4.9...v0.4.10) #### What's Changed - Fix FIFO handling on Solaris by [@​greatroar](https://togithub.com/greatroar) in [https://github.com/pkg/xattr/pull/70](https://togithub.com/pkg/xattr/pull/70) - Add support for go 1.21 by [@​kuba--](https://togithub.com/kuba--) in [https://github.com/pkg/xattr/pull/72](https://togithub.com/pkg/xattr/pull/72) - Detect the need to increase buffer size on TrueNAS SCALE. by [@​erikrose](https://togithub.com/erikrose) in [https://github.com/pkg/xattr/pull/73](https://togithub.com/pkg/xattr/pull/73) #### New Contributors - [@​erikrose](https://togithub.com/erikrose) made their first contribution in [https://github.com/pkg/xattr/pull/73](https://togithub.com/pkg/xattr/pull/73) **Full Changelog**: pkg/xattr@v0.4.9...v0.4.10 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/canonical/lxd). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
On Solaris, files need to be opened to obtain or change their attributes. But opening a FIFO file causes the calling thread to block until the write end is opened. Files are now opened using O_NONBLOCK to prevent this from happening.
Should fix restic/restic#4003.
Also fix comment on stringsFromByteSlice.
This code compiles, but I've not been able to test it without access to a Solaris box. I'm hoping @andy-js, @gco, and/or @racingmars can review/test this.